package com.woniuxy.carlife.carlifecomprehensiveweb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniuxy.carlife.carlifecomprehensiveweb.domain.Rescue;
import com.woniuxy.carlife.carlifecomprehensiveweb.dto.RescueDto;
import com.woniuxy.carlife.carlifecomprehensiveweb.mapper.RescueMapper;
import com.woniuxy.carlife.carlifecomprehensiveweb.param.RescueParam;
import com.woniuxy.carlife.carlifecomprehensiveweb.service.RescueService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

/**
 * @ClassName: RescueServiceImpl
 *@Description: 服务实现类
 * @author: yanzhongliang     
 * @date: 2021-04-05
 */

@Service
public class RescueServiceImpl extends ServiceImpl<RescueMapper, Rescue> implements RescueService {

    @Resource
    private RescueMapper rescueMapper;

    /**
     * 功能描述〈新增门店救援记录〉
     * @author: yanzhongliang
     * @param: RescueParam
     * @return: int
     * @Date 2021/4/15 14:52
     * @throws
     */

    @Override
    public int setRsecueInfolist(RescueParam rescueParam) {
        //建一个新的门店救援对象
        Rescue rescue=new Rescue();
        //存入救援地址
        rescue.setRescueAddress(rescueParam.getRescueAddress());
        //存入救援现场图片
        rescue.setRescueImage(rescueParam.getRescueImage());
        //存入救援地址纬度
        rescue.setRescueLatitude(rescueParam.getRescueLatitude());
        //存入被救援车主的车牌号
        rescue.setRescueLicense(rescueParam.getRescueLicense());
        //存入被救援车主电话
        rescue.setRescuePhone(rescueParam.getRescuePhone());
        //存入救援地址精度
        rescue.setRescuePrecision(rescueParam.getRescuePrecision());
        //存入救援收费
        rescue.setRescuePrice(rescueParam.getRescuePrice());
        //存入救援门店
        rescue.setRescueStore(rescueParam.getRescueStore());
        //存入救援门店手机号
        rescue.setRescueStorePhone(rescueParam.getRescueStorePhone());
        //存入救援时间
        rescue.setRescueTime(rescueParam.getRescueTime());
        //存入被救援车主名
        rescue.setRescueUserName(rescueParam.getRescueUserName());
        //存入被救援车型
        rescue.setRescueVehicle(rescueParam.getRescueVehicle());
        //调用新增方法
        rescueMapper.insert(rescue);
        //新增成功返回o
        return 0;
    }

    /**
     * 功能描述〈根据车牌号查询救援记录〉
     * @author: yanzhongliang
     * @param: rescueLicense
     * @return: RescueDto
     * @Date 2021/4/15 17:29
     * @throws
     */

    @Override
    public List<RescueDto> getRescueListAndRescueLicense(String rescueLicense) {
       //调用根据车牌号查救援记录方法
       List<RescueDto>list=rescueMapper.getRescueListAndRescueLicense(rescueLicense);
       //判断查询结果是否为空
       if (!list.isEmpty()){
           return list;
       }else {
           return null;
       }

    }

    /**
     * 功能描述〈查询全部救援记录〉
     * @author: yanzhongliang
     * @param: null
     * @return: RescueDto
     * @Date 2021/4/15 17:29
     * @throws
     */

    @Override
    public List<Rescue> getRescueList() {
        //调用查询所有道路救援记录
        List<Rescue> list=rescueMapper.selectList(null);
        //判断查询结果是否为空
        if (!list.isEmpty()){
            return list;
        }else {
            return null;
        }
    }
}
